# Maintainer: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Maintainer: arjan5 <aur@anymore.nl>

pkgname=jpeg-archive
pkgver=2.2.0
pkgrel=3
pkgdesc='Utilities for archiving JPEGs for long term storage'
arch=(loong64 x86_64)
url="https://github.com/danielgtaylor/jpeg-archive/"
license=(MIT)
depends=(bash)
makedepends=(git nasm)
optdepends=('parallel: for jpeg-archive'
            'dcraw: for jpeg-archive'
            'perl-image-exiftool: for jpeg-archive')
_commit=f51c5cefeb9fe5207835cc9cc2422f3950ab787a # 2.2.0
_mozjpeg_commit=72d249b89ca348c991d5e27c82cf32ba0f12d05a # v3.2
source=(git+https://github.com/danielgtaylor/jpeg-archive.git#commit=$_commit
        git+https://github.com/mozilla/mozjpeg.git#commit=$_mozjpeg_commit
        parallel.config)
sha256sums=('SKIP'
            'SKIP'
            '6a79ff5ed4b473f0515092b2a0105d6c8e38935020369e336a6a486f89de7a01')

build() {
  cd "$srcdir/mozjpeg"
  CFLAGS+=' -fcommon' # https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common
  autoreconf -fiv
  ./configure --with-jpeg8 --prefix="$srcdir/jpeg-archive/mozjpeg"
  make
  make install

  cd "$srcdir/jpeg-archive"
  MOZJPEG_PREFIX="$srcdir/jpeg-archive/mozjpeg" make
}

package() {
  cd "$srcdir/jpeg-archive"
  make PREFIX="$pkgdir/usr" install
  install -Dm644 "$srcdir/parallel.config" \
    "$pkgdir/usr/share/$pkgname/parallel.config"

  install -d "$pkgdir/usr/share/licenses/$pkgname"
  tail -n7 README.md > "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
